﻿@using KPIS.GERP.Models.ICM
@model PrePurchaseRequest

@{
    ViewBag.Title = "แจ้งความประสงค์ขอซื้อ/จ้าง [PP]";
    ViewBag.Descr = "ข้อมูลที่หน่วยงานต่างๆ ส่งความประสงค์ขอซื้อ/จ้างเข้ามาที่หน่วยงานพัสดุ";
    bool emptyLayout = false;
    if (CompareUtility.IsStringsEqual(Request["EmptyLayout"], "true") || CompareUtility.IsStringsEqual(Request["NoLayout"], "true") || GimsUtilities.ContentOnly)
    {
        Layout = "~/Views/Shared/_EmptyLayout.cshtml"; 
    }
    if (CompareUtility.IsStringsEqual(Request["EmptyLayout"], "true") || CompareUtility.IsStringsEqual(Request["NoLayout"], "true")  )
    { 
        ViewBag.EmptyLayout = true;
        emptyLayout = true;
    }
}

@using (Html.BeginForm("Create", "PrePurchase", FormMethod.Post, new { @class = "form-horizontal" }))
{
    @Html.Hidden("EmptyLayout", emptyLayout)
    @Html.AntiForgeryToken()
    @Html.Hidden("RequestEmpId", KPIS.GERP.WEB.GIMS.Class.GimsMembership.CurrentEmpId)
    <div class="block-button-menu-above">
        <a class="btn button-standard-width btn-small btn-gray" data-rel="tooltip" href="@Url.Action("Index")" role="button"><i class="icon-reply bigger-120"></i>&nbsp;&nbsp;กลับไปหน้าแสดงข้อมูลทั้งหมด</a>
        @Html.ButtonSubmit()
    </div>
    @Html.ValidationSummary(true, KPIS.GERP.Models.Class.ValidateText.RequiredField, new { @class = "alert alert-error" })
    @Html.Partial("_EditorForm")

}

@section scripts
{
	<script>

		$("form").submit(function (e) {
			e.preventDefault();
			var currentForm = this;
			bootbox.confirm(function (result) {
				if (result) {
					currentForm.submit();
				}
			});
		});
        
		$(function () {
			ChangeEnableDurType();
		});
		
		$('input[name=DurTypeId]').change(ChangeEnableDurType);
        
		function ChangeEnableDurType() {
			if ($('#durType2radio').is(':checked')) {
				$('#RequireDuration').attr('disabled', '');
				$('#DurTypeId').attr('disabled', '');
				$('#DurCountId').attr('disabled', '');
				$('#RequireDate').removeAttr('disabled');
			} else {
				$('#RequireDuration').removeAttr('disabled');
				$('#DurTypeId').removeAttr('disabled');
				$('#DurCountId').removeAttr('disabled');
				$('#RequireDate').attr('disabled', '');
			}
		}

	</script>
}